<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>添加模型字段页面</title>
<css file='__PUBLIC__/css/base.css' />
<jquery />
<js file='__PUBLIC__/js/iframe.js' />
<js file='__PUBLIC__/js/field.js' />
<script src="__DATA__/validate.min.js" language="javascript"></script>
    </head>
    <body style="padding:10px;">
        <div class="now_path">
            <strong>您现在的位置：</strong>
            <a href="__CONTROL__/index">字段管理</a> > 添加字段
        </div>
		<fieldset class='field_tishi'>
			<legend>操作提示</legend>
			增加字段或者修改字段之后，请记得必须更新缓存
		</fieldset>
		<div class="success_box">所有的选项都填写正确</div>
    	<div class="error_box"></div>
        <form action="__CONTROL__/field_add_exe" method="post" name='model'>
            <input type="hidden" name="mid" value="{$hd.get.mid}"/>
                    <table class="table2">
                        <tr>
                            <th>字段名称：</th>
                            <td><input type="text" name="fname" style="width:260px;"/>
                                <span class="desc">必须输入英文</span></td>
                        </tr>
                        <tr>
                            <th>字段标题：</th>
                            <td><input type="text" name="title" style="width:380px;"/>
                                <span class="desc">说明标题(中文)</span>
                        </tr>
                        <tr>
                            <th>字段描述：</th>
                            <td><textarea name="description" style="width:460px; height:60px;"></textarea></td>
                        </tr>
                        <tr>
                            <th>主表字段：</th>
                            <td>
                                <input type="radio" name="tablename" value="{$model.ptable}" />是&nbsp;&nbsp;
                                <input type="radio" name="tablename" value="{$model.stable}" checked="checked"/>否 
                            </td>
                        </tr>
                        <tr>
                            <th>字段类型：</th>
                            <td>
                                <select name="type" id="type">
                                    <option value="">选择类型</option>
                                    <option value="text">单行文本</option>
                                    <option value="textarea">多行文本</option>
                                    <option value="radio">单选框</option>
                                    <option value="checkbox">复选框</option>
                                    <option value="editor">编辑器</option>
                                    <option value="int">数字</option>
                                    <option value="upload">文件上传</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th>详细设置：</th>
                            <td>
                                <div id="fieldset">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th>正则验证规则：</th>
                            <td>
                                <input type="text" name="validate" style="width:460px;"/>
                                <span class="desc">验证规则正则表达式</span>
                            </td>
                        </tr>
                        <tr>
                            <th>启用：</th>
                            <td>
                                <input type="radio" name="state" value="1" checked="checked"/>是&nbsp;&nbsp;
                                <input type="radio" name="state" value="0" />否 
                            </td>
                        </tr>

                    </table>

                <div style="padding-left:100px;">
                    <input type="submit" value="添加字段" class="submit"  id='modify_field_sub' name="submit"/>
                </div>
        </form>
	<script type='text/javascript'>
		var SELECTOR_ERRORS = document.getElementById('error_box');
		var validator = new FormValidator('model', [{
		    name: 'fname',
		    display: '模型名称',    
		    rules: 'required|alpha'
		},{
    		name: 'title',
			display: '字段标题',
    		rules: 'required'
		},{
			name:'type',
			display:'字段类型',
			rules:'required',
		}
		], function(errors, event) {
		    var SELECTOR_ERRORS = $('.error_box'),
		        SELECTOR_SUCCESS = $('.success_box');
		        
			    if (errors.length > 0) {
			        SELECTOR_ERRORS.empty();
			        
			        for (var i = 0, errorLength = errors.length; i < errorLength; i++) {
			            SELECTOR_ERRORS.append(errors[i].message + '<br />');
			        }
			        
			        SELECTOR_SUCCESS.css({ display: 'none' });
			        SELECTOR_ERRORS.fadeIn(200);
			    } else {
			        SELECTOR_ERRORS.css({ display: 'none' });
			        SELECTOR_SUCCESS.fadeIn(200);
			    }
			    
			    if (event && event.preventDefault) {
			        event.preventDefault();
			    } else if (event) {
			        event.returnValue = false;
			    }
		});
	</script>
    </body>
</html>
